trigger CannotDeletePlanAndVisitBeforeThisMonth on Routing_Plan_And_Visit__c (before delete)
{
    Profile prf = [Select p.Name, p.Id From Profile p where Name='System Administrator' or Name='系统管理员' LIMIT 1 ];
    if (prf.Id != UserInfo.getProfileId())
    {
        Date currDate = System.today();
        for(Routing_Plan_And_Visit__c plan : trigger.old)
        {
            if((plan.Visit_Date__c.year() == currDate.year() && plan.Visit_Date__c.month() <= currDate.month())
             || plan.Visit_Date__c.year() < currDate.year())
            {
                plan.addError('请勿删除本月及以前的拜访计划和店内执行！');
            }
        }
    }
}